<template>
    <hd-login :loginStyle="loginStyle" ref="hdLogin" class="hd-login" :fun="beforeLogin">
        <div class="login-con">
            <div class="login-title">
                <img src="../../../assets/images/login-title3.png">
            </div>
            <div class="form-con">
                <login-form @on-success-valid="handleSubmit"></login-form>
                <!--<div class="login-tip">
                    <a @click="showChangePwdAction">修改密码</a>
                </div>-->
            </div>
        </div>
        <change-pwd :show="showChangePwd" @cancelShow="showChangePwd=false"></change-pwd>
    </hd-login>
</template>

<script>

import LoginForm from './login-form'
import bg2 from '@/assets/images/login-bg2.png'
import bg3 from '@/assets/images/login-bg3.jpg'
import { mapActions } from 'vuex'
import ChangePwd from '@/views/pages/login2/change-pwd/index'
// import { login } from '@/api/user'

export default {
  components: { ChangePwd, LoginForm },
  data () {
    return {
      loginStyle: {
        // backgroundImage: 'url(http://house-manager.oss-cn-qingdao.aliyuncs.com/login-bg.png)'
        backgroundImage: ''
      },
      showChangePwd: false,
      shiPinShow: false,
      bgImg: bg2,
      area: '',
      flg: ''
    }
  },
  methods: {
    handleSubmit (data) {
      console.log(data)
      if (data.password === '000000') {
        if (data.userName === 'dadong') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E5%25A4%25A7%25E4%25B8%259C%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f&qxmc=大东区&flg=n'
        } else if (data.userName === 'huanggu') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E7%259A%2587%25E5%25A7%2591%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f&qxmc=皇姑区&flg=n'
        } else if (data.userName === 'hunnan') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B5%2591%25E5%258D%2597%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f&qxmc=浑南区&flg=n'
        } else if (data.userName === 'yuhong') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E4%25BA%258E%25E6%25B4%25AA%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f&qxmc=于洪区&flg=n'
        } else if (data.userName === 'shenbei') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B2%2588%25E5%258C%2597%25E6%2596%25B0%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f&qxmc=沈北新区&flg=n'
        } else if (data.userName === 'sujiatun') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E8%258B%258F%25E5%25AE%25B6%25E5%25B1%25AF%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=苏家屯区&flg=n'
        } else if (data.userName === 'shenhe') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B2%2588%25E6%25B2%25B3%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=沈河区&flg=n'
        } else if (data.userName === 'tiexi') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E9%2593%2581%25E8%25A5%25BF%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=铁西区&flg=n'
        } else if (data.userName === 'heping') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E5%2592%258C%25E5%25B9%25B3%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=和平区&flg=n'
        } else if (data.userName === 'xinmin') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%2596%25B0%25E6%25B0%2591%25E5%25B8%2582.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=新民市&flg=n'
        } else if (data.userName === 'faku') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B3%2595%25E5%25BA%2593%25E5%258E%25BF.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=法库县&flg=n'
        } else if (data.userName === 'kangping') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E5%25BA%25B7%25E5%25B9%25B3%25E5%258E%25BF.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=康平县&flg=n'
        } else if (data.userName === 'liaozhong') {
          window.location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E8%25BE%25BD%25E4%25B8%25AD%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485&qxmc=辽中区&flg=n'
        } else if (data.userName === 'shenyang') {
          window.location.href = 'http://59.197.229.207:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7.frm&ref_t=design&ref_c=28f607d2-c89a-414a-87db-a528c6732387'
        }
      } else {
        this.$Message.error('密码错误')
      }
      // login(data).then(ret => {
      //   let result = ret.data
      //   if (result.data.errcode === 0 && result.errcode === 0) {
      //     this.$Message.success('登录成功！')
      //     // 判断区县和市长状态控制跳转
      //     if (this.area || this.flg) {
      //       switch (this.area) {
      //         case '大东区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E5%25A4%25A7%25E4%25B8%259C%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f'
      //           break
      //         case '皇姑区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E7%259A%2587%25E5%25A7%2591%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f'
      //           break
      //         case '浑南区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B5%2591%25E5%258D%2597%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f'
      //           break
      //         case '于洪区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E4%25BA%258E%25E6%25B4%25AA%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f'
      //           break
      //         case '沈北新区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B2%2588%25E5%258C%2597%25E6%2596%25B0%25E5%258C%25BA.frm&ref_t=design&ref_c=86d613fc-2fdc-43ec-aabd-fd857407af9f'
      //           break
      //         case '苏家屯区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E8%258B%258F%25E5%25AE%25B6%25E5%25B1%25AF%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '沈河区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B2%2588%25E6%25B2%25B3%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '铁西区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E9%2593%2581%25E8%25A5%25BF%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '和平区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E5%2592%258C%25E5%25B9%25B3%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '新民市':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%2596%25B0%25E6%25B0%2591%25E5%25B8%2582.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '法库县':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E6%25B3%2595%25E5%25BA%2593%25E5%258E%25BF.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '康平县':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E5%25BA%25B7%25E5%25B9%25B3%25E5%258E%25BF.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //         case '辽中区':
      //           location.href = 'http://59.197.229.208:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7_%25E8%25BE%25BD%25E4%25B8%25AD%25E5%258C%25BA.frm&ref_t=design&ref_c=b2227fde-b9de-4922-bb4c-4c4d4d154485'
      //           break
      //       }
      //       if (this.flg === 'y') {
      //         location.href = 'http://59.197.229.207:8080/webroot/decision/view/form?viewlet=%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7.frm&ref_t=design&ref_c=28f607d2-c89a-414a-87db-a528c6732387'
      //       }
      //       // location.href = 'http://59.197.229.207:8080/webroot/decision/view/form?area=' + this.area + '&flg=' + this.flg + '&viewlet=%252F%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7.frm&__parameters__=%257B%2522__pi__%2522%253Atrue%257D&_=1582775219057'
      //     } else {
      //       location.href = 'http://59.197.229.207:8080/webroot/decision/view/form?viewlet=%252F%25E7%2596%25AB%25E6%2583%2585%25E7%259B%2591%25E6%258E%25A7.frm&__parameters__=%257B%2522__pi__%2522%253Atrue%257D&_=1582775219057'
      //     }
      //   } else {
      //     this.$Message.error(result.errmsg)
      //   }
      // })
    },
    ...mapActions([
      'getUserInfo'
    ]),
    async beforeLogin () {
      await this.getUserInfo()
      this.$log()
      return true
    },
    showChangePwdAction () {
      this.showChangePwd = true
    },
    init () {
      this.area = this.$route.query && this.$route.query.area
      this.flg = this.$route.query && this.$route.query.flg
      console.log(this.area, '--', this.flg)
      this.loginStyle.backgroundImage = this.area && this.flg ? 'url(' + bg3 + ')' : 'url(' + bg2 + ')'
    }
  },
  mounted () {
    this.init()
  }

}
</script>
<style lang="less" scoped>
    .bg-orange {
        border-radius: 4px 4px 0px 0px;
        position: absolute;
        width: 100%;
        height: 10px;
        /*background-color: #fed731;*/
        top: 0px;
        left: 0px;
    }

    .welcome-title {
        margin-top: 10px;
        text-align: center;
    }
    .login-title {
        width: 100%;
        text-align: center;
        margin-bottom: 20px;
    }
    .login-title img{
        width: 100%;
    }

    .hd-login {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .hd-login .login-con {
        position: relative;
        top: 20%;
        right: 0px;
        width: 450px;
    }

    .hd-login /deep/ .wl-pwd .ivu-input-group-prepend {
        padding: 8px;
    }

    .login-tip {
        text-align: center;
        font-size: 14px;
    }

</style>
